//
//  StatusCell.m
//  Weibo
//
//  Created by Anasue on 9/16/15.
//  Copyright (c) 2015 Anasue. All rights reserved.
//

#import "StatusCell.h"
#import "StatusDetailView.h"
#import "StatusToolBar.h"
#import "StatusDetailViewFrame.h"
#import "StatusFrame.h"

@interface StatusCell ()
@property (nonatomic, weak) StatusDetailView *detailView;
@property (nonatomic, weak) StatusToolBar *toolBarView;


@end

@implementation StatusCell

+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *identifier = @"cell";
    StatusCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[StatusCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        //1.创建控件DetailView
        [self setupStatusDetailView];
        //2.创建toolbarView
        [self setupStatusToolBarView];
        
        self.backgroundColor = [UIColor clearColor];
//        self.backgroundColor = RandomColor;
        
    }
    return self;
}

/**
 *  创建控件DetailView

 */
- (void)setupStatusDetailView
{
    StatusDetailView *detailView = [[StatusDetailView alloc]init];
    [self.contentView addSubview:detailView];
    self.detailView = detailView;
}

/**
 *  创建toolbarView
 */
- (void)setupStatusToolBarView
{
    StatusToolBar *toolBarView = [[StatusToolBar alloc]init];
    [self.contentView addSubview:toolBarView];
    self.toolBarView = toolBarView;
}

- (void)setStatusFrame:(StatusFrame *)statusFrame
{
    _statusFrame = statusFrame;
    
    self.detailView.detailViewFrame = statusFrame.detailViewFrame;
    self.toolBarView.frame = statusFrame.toolBarFrame;
    self.toolBarView.status = statusFrame.status;

}

@end
